from rest_framework.pagination import PageNumberPagination
from collections import OrderedDict
from rest_framework.response import Response


class MyPagination(PageNumberPagination):
    page_size = 3
    page_size_query_param = 'pagesize'
    page_query_param = 'page'
    max_page_size = 10

    def get_paginated_response(self, data):
        return Response(OrderedDict([
            ('count', self.page.paginator.count),
            ('results', data)
        ]))